from tile import *
import random
import string

'''
' Class to manage the board state
'''
class Board(object):
    def __init__(self, width=5, height=5):
        # initiate dict of all tiles
        self.tiles = {}
        for x in xrange(5):
            for y in xrange(5):
                self.tiles[(x, y)] = Tile(random.choice(string.ascii_lowercase), x, y)
        
        # initate other tile dicts
        self.unused_tiles = self.tiles
        self.player_tiles = {}
        self.ai_tiles = {}
        
        # states
        self.PLAYER_TURN = 0
        self.AI_TURN = 1
        
        # randomly select who begins first
        self.turn = random.randint(self.PLAYER_TURN, self.AI_TURN)
    
    def get_all_letters(self):
        letters = []
        for key in self.tiles:
            letters.append(self.tiles[key].letter)
        return letters
        
    def get_tile(self, x, y):
        return self.tiles[(x ,y)]
    
    def get_turn(self):
        return self.turn
    
    def get_unused_tiles(self):
        return self.unused_tiles
    
    def get_player_tiles(self):
        return self.player_tiles
    
    def get_ai_tiles(self):
        return self.ai_tiles
    
    def use_turn(self, tile_tuples):
        for tile_tuple in tile_tuples:
            break
            